package edu.cueb.wmis.controller;


import edu.cueb.wmis.pojo.*;
import edu.cueb.wmis.service.IGoodService;
import edu.cueb.wmis.service.IHouseService;
import edu.cueb.wmis.service.IShelfService;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author liuzizhuo
 * @since 2021-04-19
 */
@RestController
@RequestMapping("/good")
public class GoodController {
    @Autowired
    private IGoodService goodService;
    @Autowired
    private IHouseService houseService;
    @Autowired
    private IShelfService shelfService;

    @ApiOperation(value = "实现分页查询库存")
    @GetMapping("/")
    public RespPageBean getAllGood(@RequestParam(defaultValue = "1") Integer currentPage
                                    , @RequestParam(defaultValue = "20") Integer size
                                    , Good good){
        System.out.println(good);
        return goodService.getAllGood(currentPage,size,good);
    }
    @ApiOperation(value = "根据名称获取剩余库存")
    @GetMapping("/storenumber")
    public RespBean getGoodStoreNumberByID(@RequestParam String gname){
        return goodService.getGoodStoreNumberByName(gname);
    }
    @ApiOperation(value = "查询库存为空的物品")
    @GetMapping("/zero/goods")
    public List<Good> getGoodZero(){
        return goodService.getGoodZero();
    }

    @ApiOperation(value = "查询空货架")
    @GetMapping("/zero/shelves")
    public List<Shelf> getShelfZero(){
        return goodService.getShelfZero();
    }
    @ApiOperation(value = "查询空货架的零库存物品")
    @GetMapping("/zero/nullGoods")
    public List<Good> getNullGoods(){
        return goodService.getNullGoods();
    }

    @ApiOperation(value = "获得所有仓库（列表）")
    @GetMapping("/houses")
    public List<House> getHouses(){
        return houseService.list();
    }

    @ApiOperation(value = "根据仓库id返回货架列表")
    @GetMapping("/shelfs/{hid}")
    public List<Shelf> getShelfs(@PathVariable Integer hid){
        System.out.println(hid);
        return shelfService.getShelfsByHouseId(hid);
    }

    @ApiOperation("根据仓库id 查询该仓库有什么东西")
    @GetMapping("/byHouse/{hid}")
    public List<Good> getGoodsByHouseId(@PathVariable Integer hid){
        return goodService.getGoodsByHouseId(hid);
    }

    @ApiOperation("根据货架id 返回物品 及其剩余数")
    @GetMapping("/byShelf/{sid}")
    public List<Good> getGoodsByShelfId(@PathVariable Integer sid){
        return goodService.getGoodsByShelfId(sid);
    }

    //public RespBean getGoo
}
